package com.lei.zjs.service.ebo;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lei.zjs.dao.StaffDao;
import com.lei.zjs.service.ebi.StaffService;
import com.lei.zjs.vo.PageBean;
import com.lei.zjs.vo.Staff;

@Service
@Transactional
public class StaffServiceImpl implements StaffService {

	@Resource
	private StaffDao staffDao;

	@Override
	public void save(Staff model) {
		staffDao.save(model);
	}

	@Override
	public List<Staff> showAll(int page, int rows) {
		Integer start = (page - 1) * rows;
		return staffDao.findByPage(start,rows);
	}

	@Override
	public Long getCount() {
		return staffDao.findCount();
	}

	@Override
	public void delete(String ids) {
		String[] idArr = ids.split(",");
		for (String id : idArr) {
			Staff staff = staffDao.findById(id);
			staff.setDeltag("1");
		}
	}

	@Override
	public void restore(String ids) {
		String[] idArr = ids.split(",");
		for (String id : idArr) {
			Staff staff = staffDao.findById(id);
			staff.setDeltag("0");
		}
	}

	@Override
	public Staff getStaff(String id) {
		return staffDao.findById(id);
	}

	@Override
	public void update(Staff model) {
		staffDao.update(model);
	}

	@Override
	public void pageQuery(PageBean pageBean) {
		staffDao.pageQuery(pageBean);
	}

	@Override
	public List<Staff> findByConditions(DetachedCriteria dc) {
		return staffDao.findByCriteria(dc);
	}
}
